package operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-18
 * Time: 8:17
 */
public class SerachOpeartion implements IOperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("查找图书！");
        System.out.println("请输入你要查找的书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        for (int i = 0; i <booklist.getUseSize() ; i++) {
            if(booklist.getBooks(i).getName().equals(name)){
                System.out.println("找到了！");
                System.out.println(booklist.getBooks(i));
                return;
            }
        }
        //程序运行到这里，没有找到这本书
        System.out.println("没有找到！");
    }
}
